<?php
// +----------------------------------------------------------------------
// | Author: ZYN Fl
// +----------------------------------------------------------------------
namespace app\admin\controller;
use think\Controller;
use think\Request;
use think\Db;

class Menu extends Controller
{
    public function index()
    {
    	$data=Db::name('menu')->select();
    	$cat=gettree($data,0);
    	// dump($cat);die;
    	$this->assign("cat",$cat);
        return $this->fetch();
    }
    // 添加菜单
    public function addonemenu(){
    	// return 1;
    	$mname = input('mname');
    	// return $mname;
    	$murl = input('murl');
    	// return $murl;
    	$mplace = input('mplace');
    	// return $mplace;
    	$date = array(
    			'mname' => $mname,
    			'murl' => $murl,
    			'mplace' => $mplace
    		);
    	// return $date;
    	$menu=Db::name('menu')->insert($date);
    	if($menu){
    		return 1;
    	}
    }
    //添加一级菜单
     public function addtwomenu(){
    	// return 1;
    	$mname = input('mname');
    	$mplace = input('mplace');
    	$parent_cid = input("parent_cid");
    	// return $mplace;
    	$date = array(
    			'mname' => $mname,
    			'mplace' => $mplace,
    			'parent_cid' => $parent_cid
    		);
    	// return $date;
    	$menu=Db::name('menu')->insert($date);
    	if($menu){
    		return 1;
    	}
    }
}